﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using IronOne.SalesOne.BusinessObjects;

namespace IronOne.SalesOne.SalesOneWeb.UserManagement
{
    public partial class ManageUserRoles : System.Web.UI.Page
    {
        Facade.StructureFacade structureFacade = new Facade.StructureFacade();

        protected void Page_Load(object sender, EventArgs e)
        {
            SetDataSourceToTypes(structureFacade.GetUserType(""));
        }

        protected void btnCreateRole_Click(object sender, EventArgs e)
        {
            if (!Roles.RoleExists(txtRole.Text))
            {
                Roles.CreateRole(txtRole.Text);
            }

            /*Get Role by name*/

            /*Get ID of the record*/

            /*Get Other Records */

            /*Insert To DataBase*/
            //

        }

        protected void ddlRoleType_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        public void SetDataSourceToTypes(List<UserType> userTypes)
        {
            ddlRoleType.DataSource = userTypes;
            ddlRoleType.DataTextField = "UserTypeName";
            ddlRoleType.DataValueField = "UserTypeId";
            ddlRoleType.DataBind();


            InsertDDLItems(ddlRoleType, "Select...", 0);
            //InsertDDLItems(ddlFrom, "Select All", 1);
        }

        public void InsertDDLItems(DropDownList ddl, string Text, int Position)
        {
            ddl.Items.Insert(Position, Text);
        }
    }
}
